package com.zq.designpaterns.structure.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * ================================================
 * 作    者：程志强
 * 邮    箱：cheng.zhiqiang@cesgroup.com.cn
 * 版    本：1.0.0
 * 创建日期：2021/01/12  11:21
 * 修改日期：
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class Employee {
    /**
     * 姓名
     */
    private String name;
    /**
     * 部门
     */
    private String dept;
    /**
     * 薪水
     */
    private int salary;
    /**
     * 下属
     */
    private List<Employee> subordinates;

    public Employee(String name, String dept, int salary) {
        this.name = name;
        this.dept = dept;
        this.salary = salary;
        subordinates = new ArrayList<>();
    }

    /**
     * 添加下属
     *
     * @param e
     */
    public void add(Employee e) {
        subordinates.add(e);
    }

    /**
     * 移除下属
     *
     * @param e
     */
    public void remove(Employee e) {
        subordinates.remove(e);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public List<Employee> getSubordinates() {
        return subordinates;
    }

    public void setSubordinates(List<Employee> subordinates) {
        this.subordinates = subordinates;
    }

    @Override
    public String toString() {
        return "Employee：【" +
                "name='" + name + '\'' +
                ", dept='" + dept + '\'' +
                ", salary=" + salary +
                '】';
    }
}
